package com.bys.controller;

import com.bys.entity.OrderPay;
import com.bys.util.Result;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class PayController {
    @Resource
    private RestTemplate restTemplate;
    @GetMapping("/consumer/string/getId/{payId}")
    public String getId(@PathVariable Integer payId){
        String payGet = "http://EDU-EUREKA-PROVIDER/pay/string/getId/";
        return restTemplate.getForObject(payGet + payId, String.class, payId);
    }
    @GetMapping("/consumer/pay/getId/{payId}")
    public Result getById(@PathVariable Integer payId){
        String payGet = "http://localhost:8083/pay/getId/";
        return restTemplate.getForObject(payGet + payId, Result.class, payId);
    }
    @PostMapping("/consumer/pay/create")
    public Result createOrderPay(@RequestBody  OrderPay orderPay){
        String payPostCreate = "http://localhost:8083/pay/create";
        Result result = restTemplate.postForObject(payPostCreate,orderPay,Result.class);
        System.out.println(result);
        return  Result.success();
    }
}
